package cn.yunyichina.openapi.sdk.client;

import cn.yunyichina.openapi.sdk.utils.ApiUtil;

/**
 * 调用服务的客户端
 *
 * @author zhangkewen
 */
public class OpenApiClient {

    /*会话sessionId*/
    private String sessionid;

    public OpenApiClient(String sessionid) {
        this.sessionid = sessionid;
    }

    public OpenApiClient() {
        this.sessionid = "";
    }

    /**/
    public String login(String loginMethod, String username, String password, int deviceType) {
        String data = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"device_type\":" + deviceType + "}";
        return ApiUtil.httpPostLogin(loginMethod, data);
    }

    /*具体请求的参数*/
    public String execute(String method, String data) {
        return ApiUtil.httpPost(sessionid, method, data);
    }

}
